Be more careful when overdrawing antialiased text. (#352435, Alex Jones,
authorMatthias Clasen <mclasen@redhat.com>
Mon, 11 Dec 2006 15:35:25 +0000 (15:35 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 11 Dec 2006 15:35:25 +0000 (15:35 +0000)
2006-12-11  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): Be more
        careful when overdrawing antialiased text.  (#352435, Alex Jones,
        patch by Benjamin Otte)

ChangeLog
gtk/gtkprogressbar.c

index 0b9b9eb59fdd22075107c4524515f2cbfd6438a2..77857f444cc51a79c3a3be0f613a164a542469a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 2006-12-11  Matthias Clasen  <mclasen@redhat.com>
 
-       * gtksettings.c: Change the way in which color scheme information
+       * gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): Be more
+       careful when overdrawing antialiased text.  (#352435, Alex Jones,
+       patch by Benjamin Otte)
+
+       * gtk/gtksettings.c: Change the way in which color scheme information
        is merged to correctly handle vanishing colors.  (#374420, 
        Benjamin Berg, patch by Callum McKenzie) 
        Also allow to separate entries in color schemes by ';' 
index 295f4143a1244c80f980f173bd497bb3a4fb925f..53b746bd64226b736f80cc1e8fde550dde1a4c2b 100644 (file)
@@ -76,6 +76,8 @@ static gboolean gtk_progress_bar_expose    (GtkWidget           *widget,
                                            GdkEventExpose      *event);
 static void gtk_progress_bar_size_request  (GtkWidget           *widget,
                                            GtkRequisition      *requisition);
+static void gtk_progress_bar_style_set     (GtkWidget           *widget,
+                                           GtkStyle            *previous);
 static void gtk_progress_bar_real_update   (GtkProgress         *progress);
 static void gtk_progress_bar_paint         (GtkProgress         *progress);
 static void gtk_progress_bar_act_mode_enter (GtkProgress        *progress);
@@ -108,6 +110,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
   
   widget_class->expose_event = gtk_progress_bar_expose;
   widget_class->size_request = gtk_progress_bar_size_request;
+  widget_class->style_set = gtk_progress_bar_style_set;
 
   progress_class->paint = gtk_progress_bar_paint;
   progress_class->update = gtk_progress_bar_real_update;
@@ -551,6 +554,17 @@ gtk_progress_bar_size_request (GtkWidget      *widget,
     }
 }
 
+static void
+gtk_progress_bar_style_set (GtkWidget      *widget,
+    GtkStyle *previous)
+{
+  GtkProgressBar *pbar = GTK_PROGRESS_BAR (widget);
+
+  pbar->dirty = TRUE;
+
+  GTK_WIDGET_CLASS (gtk_progress_bar_parent_class)->style_set (widget, previous);
+}
+
 static void
 gtk_progress_bar_act_mode_enter (GtkProgress *progress)
 {
@@ -779,7 +793,7 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
   GdkRectangle rect;
   PangoLayout *layout;
   PangoRectangle logical_rect;
-  GdkRectangle prelight_clip, normal_clip;
+  GdkRectangle prelight_clip, start_clip, end_clip;
   gfloat text_xalign = progress->x_align;
   gfloat text_yalign = progress->y_align;
 
@@ -808,7 +822,7 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
   rect.width = widget->allocation.width - 2 * widget->style->xthickness;
   rect.height = widget->allocation.height - 2 * widget->style->ythickness;
 
-  prelight_clip = normal_clip = rect;
+  prelight_clip = start_clip = end_clip = rect;
 
   switch (orientation)
     {
@@ -816,6 +830,9 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
       if (offset != -1)
        prelight_clip.x = offset;
       prelight_clip.width = amount;
+      start_clip.width = prelight_clip.x - start_clip.x;
+      end_clip.x = start_clip.x + start_clip.width + prelight_clip.width;
+      end_clip.width -= prelight_clip.width + start_clip.width;
       break;
       
     case GTK_PROGRESS_RIGHT_TO_LEFT:
@@ -824,12 +841,18 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
       else
        prelight_clip.x = rect.x + rect.width - amount;
       prelight_clip.width = amount;
+      start_clip.width = prelight_clip.x - start_clip.x;
+      end_clip.x = start_clip.x + start_clip.width + prelight_clip.width;
+      end_clip.width -= prelight_clip.width + start_clip.width;
       break;
        
     case GTK_PROGRESS_TOP_TO_BOTTOM:
       if (offset != -1)
        prelight_clip.y = offset;
       prelight_clip.height = amount;
+      start_clip.height = prelight_clip.y - start_clip.y;
+      end_clip.y = start_clip.y + start_clip.height + prelight_clip.height;
+      end_clip.height -= prelight_clip.height + start_clip.height;
       break;
       
     case GTK_PROGRESS_BOTTOM_TO_TOP:
@@ -838,18 +861,33 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
       else
        prelight_clip.y = rect.y + rect.height - amount;
       prelight_clip.height = amount;
+      start_clip.height = prelight_clip.y - start_clip.y;
+      end_clip.y = start_clip.y + start_clip.height + prelight_clip.height;
+      end_clip.height -= prelight_clip.height + start_clip.height;
       break;
     }
 
-  gtk_paint_layout (widget->style,
-                   progress->offscreen_pixmap,
-                   GTK_STATE_NORMAL,
-                   FALSE,
-                   &normal_clip,
-                   widget,
-                   "progressbar",
-                   x, y,
-                   layout);
+  if (start_clip.width > 0 && start_clip.height > 0)
+    gtk_paint_layout (widget->style,
+                     progress->offscreen_pixmap,
+                     GTK_STATE_NORMAL,
+                     FALSE,
+                     &start_clip,
+                     widget,
+                     "progressbar",
+                     x, y,
+                     layout);
+
+  if (end_clip.width > 0 && end_clip.height > 0)
+    gtk_paint_layout (widget->style,
+                     progress->offscreen_pixmap,
+                     GTK_STATE_NORMAL,
+                     FALSE,
+                     &end_clip,
+                     widget,
+                     "progressbar",
+                     x, y,
+                     layout);
 
   gtk_paint_layout (widget->style,
                    progress->offscreen_pixmap,